package cn.johnyu;

import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Service;

import java.util.concurrent.Future;

@Service
public class UserManagerImpl implements UserManager {
    @Async
    @Override
    public Future<String> work() {
        for (int i = 0; i < 10; i++) {
            try {
                Thread.sleep(500);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("working....");
        }
        AsyncResult<String> res=new AsyncResult<>("data info");
        return res;
    }
}
